
while !isOnGem {
    while !isOnClosedSwitch && !isOnGem {
        moveForward()
        
    }
    
    if isOnClosedSwitch {
        toggleSwitch()
        
    }
    
    
    if !isBlocked {
        turnRight()
        
    } else {
        turnLeft()
        
    }
    
}
collectGem()
